"""superlists URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path
# from django.conf.urls import patterns,include,url
from lists.views import home_page
from lists.views import view_list
from lists.views import new_list
from lists.views import add_item
# Django 1.10 no longer allows you to specify views as a string (e.g. 'myapp.views.home') in your URL patterns.
urlpatterns = [

    # 解析根目录应该有问题.换成''
    # 新版匹配正则re_path \d+
    # 结尾没有加$,导致add_item会匹配到(\d+)/，而不是add_item
    path('', home_page, name='home'),
    re_path('lists/(\d+)/$', view_list, name='view_list'),
    re_path('lists/(\d+)/add_item/$', add_item, name='add_item'),
    # 去掉后尾的$
    path('lists/new', new_list, name='new_list'),
    # path('home/', home_page, name='home')
    # path('admin/', admin.site.urls),
]
